<?php

use think\facade\Route;

$domain = ['Access-Control-Allow-Headers' => 'Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, X-CSRF-TOKEN, X-Requested-With, token, sign'];

//miss路由，定义404
Route::miss(function () {
    @header("http/1.1 404 not found");
    @header("status: 404 not found");
    exit();
});

//首页
Route::group('index', function () {
    Route::get('/index', 'index/index');
    Route::get('/ad', 'index/ad');
    Route::get('/communal', 'index/communal');
    Route::get('/appletOpen', 'index/appletOpen');
    Route::post('/sendSms', 'index/sendSms');
    Route::rule('/villageCode', 'index/villageCode');
});

//轮播图
Route::group('carousel', function () {
    Route::get('/index', 'carousel/index');
});

//新闻
Route::group('news', function () {
    Route::get('/index', 'news/index');
    Route::get('/info', 'news/info');
    Route::get('/notReadNum', 'news/notReadNum');
});

//店铺
Route::group('store', function () {
    Route::get('/index', 'store/index');
});

//登录相关
Route::group('login', function () {
    Route::post('/login', 'login/login');
    Route::post('/third', 'login/third');
    Route::post('/thirdBind', 'login/thirdBind');
    Route::post('/resetPassword', 'login/resetPassword');

    Route::get('/wechat', 'login/wechat');
    Route::rule('/wechat_open', 'login/wechat_open');
})->allowCrossDomain($domain);

//注册相关
Route::group('register', function () {
    Route::post('/add', 'register/add');
    Route::get('/web', 'register/web');
    Route::get('/agreement', 'register/agreement');
    Route::get('/getArea', 'register/getArea');
})->allowCrossDomain($domain);

//协议
Route::group('protocol', function () {
    Route::get('/index', 'protocol/index');
    Route::get('/privacy', 'protocol/privacy');
})->allowCrossDomain($domain);

//订单相关
Route::group('order', function () {
    Route::get('/index', 'order/index');
    Route::get('/payment', 'order/payment');
    Route::get('/my_order', 'order/my_order');
    Route::get('/my_order_details', 'order/my_order_details');
    Route::get('/getList', 'order/getList');
    Route::post('/submit', 'order/submit');
    Route::post('/confirmPayment', 'order/confirmPayment');
    Route::post('/edit', 'order/edit');
    Route::post('/invoiceApply', 'order/invoiceApply');
})->middleware('verify');

//个人中心
Route::group('user', function () {
    Route::post('/authorization', 'user/authorization');
    Route::get('/index', 'user/index');
    Route::get('/myTeam', 'user/myTeam');
    Route::get('/myTeamList', 'user/myTeamList');
    Route::get('/myContractTeam', 'user/myContractTeam');
    Route::get('/myContractTeamList', 'user/myContractTeamList');
    Route::get('/pastureMyTeam', 'user/pastureMyTeam');
    Route::get('/tillageMyTeam', 'user/tillageMyTeam');
    Route::get('/villageMyTeam', 'user/villageMyTeam');
    Route::get('/setting', 'user/setting');
    Route::get('/notify/:type', 'user/notify');
    Route::post('/edit', 'user/edit');
    Route::post('/logout', 'user/logout');
    Route::post('/signIn', 'user/signIn');//签到
    Route::get('/signInList', 'user/signInList');//签到记录
    Route::get('/signInCycle', 'user/signInCycle');//签到周期
    Route::get('/foot', 'user/foot');//我的足迹
    Route::get('/collectProduct', 'user/collectProduct');//我的收藏
    Route::get('/collectBusiness', 'user/collectBusiness');//我的关注
    Route::get('/productEvaluate', 'user/productEvaluate');//我的评论
    Route::get('/ranking', 'user/ranking');//业绩排行
    Route::get('/consumeUser', 'user/consumeUser');//消费会员
    Route::get('/service', 'user/service');
    Route::post('/realAuth', 'user/realAuth');
    Route::post('/uploadFaceImage', 'user/uploadFaceImage');
    Route::get('/discount', 'user/discount');
    Route::get('/qrcode', 'user/qrcode');
    Route::get('/myNotify', 'user/myNotify');
    Route::put('/changeMobile', 'user/changeMobile');

    Route::get('/openCancel', 'user/openCancel');//是否开启注销
    Route::put('/cancel', 'user/cancel');//用户注销
    Route::post('/bindGzhOpenid', 'user/bindGzhOpenid');
    Route::get('/villageReleaseRecord', 'user/villageReleaseRecord');
})->allowCrossDomain($domain)->middleware('verify');

//
Route::group('user', function () {
    Route::get('/gzhOpenid', 'user/gzhOpenid');
    Route::get('/getGzhOpenid', 'user/getGzhOpenid');
})->allowCrossDomain($domain);

/**
 * 视频相关
 */
Route::group('userVideo', function () {
    Route::get('/userLevel', 'userVideo/userLevel');
    Route::get('/cateList', 'userVideo/cateList');
    Route::get('/index', 'userVideo/index');
    Route::get('/info', 'userVideo/info');
    Route::post('/hit', 'userVideo/hit');
    Route::post('/comment', 'userVideo/comment');
    Route::get('/level', 'userVideo/level');
    Route::post('/buy', 'userVideo/buy');
    Route::get('/buyRecord', 'userVideo/buyRecord');
    Route::post('/getRedCoin', 'userVideo/getRedCoin');
    Route::get('/redCoinRecord', 'userVideo/redCoinRecord');
    Route::put('/upShare', 'userVideo/upShare');
})->middleware('verify');

//地址相关
Route::group('address', function () {
    Route::get('/index', 'address/index');
    Route::get('/add', 'address/add');
    Route::get('/edit/:id', 'address/edit');
    Route::post('/save', 'address/save');
    Route::delete('/delete/:id', 'address/delete');
    Route::post('/default', 'address/default');
})->allowCrossDomain($domain)->middleware('verify');
//地址相关-非必登录
Route::group('address', function () {
    Route::get('/getArea/:id/:level', 'address/getArea');
})->allowCrossDomain($domain);

//资产 - 我的账户
Route::group('account', function () {
    Route::get('/index', 'account/index');
    Route::get('/getList', 'account/getList');
})->middleware('verify');

//充值相关
Route::group('remit', function () {
    Route::get('/index', 'remit/index');
    Route::get('/record', 'remit/record');
    Route::get('/getList', 'remit/getList');
    Route::post('/save', 'remit/save');
})->middleware('verify');

//提现相关
Route::group('draw', function () {
    Route::get('/rule', 'draw/rule');
    Route::get('/record', 'draw/record');
    Route::post('/save', 'draw/save');
    Route::post('/methodSave', 'draw/methodSave');
    Route::get('/methodList', 'draw/methodList');
    Route::get('/methodInfo', 'draw/methodInfo');
    Route::get('/bankList', 'draw/bankList');
})->middleware('verify');

//转账相关
Route::group('transfer', function () {
    Route::get('/rule', 'transfer/rule');
    Route::get('/verify', 'transfer/verify');
    Route::post('/save', 'transfer/save');
    Route::get('/record', 'transfer/record');
})->middleware('verify');

//转换相关
Route::group('exchange', function () {
    Route::get('/index', 'exchange/index');
    Route::get('/record', 'exchange/record');
    Route::get('/getList', 'exchange/getList');
    Route::post('/save', 'exchange/save');
})->middleware('verify');

//意见反馈
Route::group('message', function () {
    Route::get('/index', 'message/index');
    Route::post('/save', 'message/save');
})->middleware('verify');

//安全中心
Route::group('security', function () {
    Route::get('/index', 'security/index');
    Route::post('/save', 'security/save');
})->middleware('verify');

//抽奖
Route::group('prize', function () {
    Route::get('/index', 'prize/index');
    Route::get('/record', 'prize/record');
    Route::post('/luck', 'prize/luck');
})->middleware('verify');

//上传
Route::group('uploads', function () {
    Route::rule('/uploadImage', 'uploads/uploadImage');
    Route::rule('/uploadVideo', 'uploads/uploadVideo');
})->allowCrossDomain($domain);

//合约专区-股权资料
Route::group('stockRight', function () {
    Route::get('/index', 'stockRight/index');
    Route::get('/info', 'stockRight/info');
});

//版本更新
Route::group('version', function () {
    Route::get('/index', 'version/index');
});

//实名认证
Route::group('userAuth', function () {
    Route::get('/index', 'userAuth/index');
    Route::post('/save', 'userAuth/save');
})->middleware('verify');

//测试
Route::group('test', function () {
    Route::rule('/test', 'test/test');
});